<?php ob_start();
include("../config/config.php"); 
if(!isset($_SESSION['csr_id'])){ header("location:index.php"); exit;}
$obj= new mycity();
if(isset($_REQUEST['status'])&&($_REQUEST['status']!="")){
	$status=$obj->change_status('my_business_url',$_REQUEST['id'],$_REQUEST['status']);
	if($status==1){echo "<script> alert('Page Aproved Suscessfully!!');</script>";}else{echo "<script> alert('Page Rejected Suscessfully!!');</script>";}
	header("location:inactive-pages.php"); exit;
}
if(isset($_POST['Update'])&&($_POST['Update']=="Update")){ 
	$sql=mysql_query("UPDATE `my_emails_tamplate` SET 	`emfrom` = '".$_POST['emfrom']."',
														`relemailid` = '".$_POST['relemailid']."',
														`emsubject` = '".$_POST['emsubject']."',
														`emcontent` = '".$_POST['emcontent']."' 
														  WHERE `emid` = '".$_REQUEST['id']."' ")or die(mysql_error()); 
	if($sql){ $_SESSION['msg']="Email tamplate updated suscessfully";}
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Inactive Pages</title>
<script type="text/javascript"  src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script type="text/javascript"  src="ckeditor/ckeditor/ckeditor/ckeditor.js"></script>
<script>
$(function(){ CKEDITOR.replace( 'editor1' ); });
	
</script>
<style>
*{ margin:0px; padding:0px;}
input[type='text'],input[type='submit'],select { height:30px; width:250px;}
</style>
<script>
function email(obj){
	location='emailer.php?id='+obj.value;
}
</script>
</head>

<body>

<?php if(isset($_REQUEST['id'])&&($_REQUEST['id']!='')){
	$sql=mysql_query("SELECT * FROM `my_emails_tamplate` WHERE `emid` = '".$_REQUEST['id']."' ")or die(mysql_error()); 
	$row=mysql_fetch_array($sql);
}
?>
<table width="100%" height="62" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <th width="6%" bgcolor="#009933" scope="col"> <a href="logout.php">Logout</a></th>
    <th width="6%" bgcolor="#009933" scope="col"><a href="emailer.php">Emailer</a></th>
    <th width="13%" bgcolor="#009933" scope="col"><a href="inactive-pages.php">Inactive Pages ( <?php echo $obj->count_rowall("SELECT * FROM `my_business_url` WHERE `status` = 0 "); ?> )</a></th>
    <th width="53%" bgcolor="#009933" scope="col"></th>
    <th width="12%" bgcolor="#009933" scope="col"></th>
    <th width="10%" bgcolor="#009933" scope="col"></th>
  </tr>
</table>

<div align="center">
<?php
if(isset($_SESSION['msg'])){
?>
<div style="color:red; text-align:center; font-size:16px;"><?php echo $_SESSION['msg']; unset($_SESSION['msg']); ?></div>
<?php }?>
<form action="" method="post">
  <table width="1144" height="556"  >
    <tr>
      <th width="217" scope="row"><div align="right">Email Type:</div></th>
      <td width="915"><label for="select"></label>
        <select name="title" id="select" required onchange="email(this);">
        <option value="">Select Email Type</option>
        <?php $sql=mysql_query("SELECT * FROM `my_emails_tamplate` ")or die(mysql_error()); while($row1=mysql_fetch_array($sql)){?>
        <option value="<?php echo $row1['emid']; ?>" <?php if(isset($_REQUEST['id'])&&($_REQUEST['id']==$row1['emid'])){ echo "selected";}?>><?php echo $row1['title']; ?></option>
        <?php }?>
      </select></td>
    </tr>
    <tr>
      <th scope="row"><div align="right">From:</div></th>
      <td><label for="textfield"></label>
      <input type="text" name="emfrom" id="textfield" value="<?php if(isset($row['emfrom'])){ echo $row['emfrom'];}?>" /></td>
    </tr>
    <tr>
      <th scope="row"><div align="right">Reply:</div></th>
      <td><input type="text" name="relemailid" id="textfield2"  value="<?php if(isset($row['relemailid'])){ echo $row['relemailid'];}?>" /></td>
    </tr>
    <tr>
      <th scope="row"><div align="right">Subject:</div></th>
      <td><input type="text" name="emsubject" id="textfield3"  value="<?php if(isset($row['emsubject'])){ echo $row['emsubject'];}?>" /></td>
    </tr>
    <tr>
      <th height="361" colspan="3" scope="row"> <label for="textarea"></label>        <textarea name="emcontent"   id="editor1" cols="150" rows="20"><?php if(isset($row['emcontent'])){ echo $row['emcontent'];}?></textarea></th>
      </tr>
    <tr>
      <th scope="row"><div align="right"></div></th>
      <td><input type="submit" name="Update" id="button" value="Update" /></td>
    </tr>
  </table>
  </form>
</div>

</body>
</html>